"use strict";
advertiserApp.controller("advertiserCtrl",function($scope,$http){	 
	 $http.post("/web-adv/finishPlacementAd").success(function(data){
		 $scope.tableData = data.beans;	
		 //console.log($scope.tableData)		 
	 });
	 //时间格式转换
	 $scope.translate = function(t){
		 t = t.replace(/-/g,'/');
		 t = t.split(".")[0];		 
		 var date = new Date(t);		 
		 return date.getTime();
	 };	 
	 // 删除已投放广告（伪删除）	  
	 $scope.deleteAd = function(id){
		 var msg = "您确定要删除此条广告吗？";
			if (confirm(msg)){			
				$.ajax({
					url : '/web-adv/deletePlacementAd',
			        data:{adId:id},
					type : 'post',
					success : function(data) {			
						if(data.status =='1'){
							$http.post("/web-adv/finishPlacementAd").success(function(data){
								$scope.tableData = data.beans;									
							});
						}else{
							console.log("删除失败！");
						}
					},
			        error: function(){}        
				});
			};		 
	 };
	 $scope.details = function(value){
		 if(value=="video") return true;
		 return false;		 
	 }
	
});




